<template>
	<view class="container">
		<view class="person-info-container" v-if="followList.length > 0">
			<view class="person-info new-border" v-for="(item, index) in followList" :key="index">
				<view class="person-info__header">
					<image class="person-info__header-img" :src="item.ServePlayerHeadImg"></image>
					<view style="margin-left: 20rpx;">
						<view>
							<text>{{ item.ServePlayerName }}</text>
						</view>
						<text class="user-content">{{ item.Sign }}</text>
					</view>
				</view>
				<view class="person-info__bottom">
					<view>
						<text>Lv.{{ item.Level }}</text>
					</view>
					<view class="person-info__bottom-item">
						<image class="person-info__bottom-icon" src="../../../static/images/star.png"></image>
						<text>{{ item.StarTotal }}</text>
					</view>
					<view class="person-info__bottom-item">
						<image class="person-info__bottom-icon" src="../../../static/images/praise-heart.png"></image>
						<text>{{ item.LikeCount }}</text>
					</view>
					<view class="flow-btn" @click="cancel_attention(item.ServePlayerId)">取消关注</view>
				</view>
			</view>
		</view>
		<view v-else class="no-content">暂无内容</view>
	</view>
</template>

<script>
import { isLogin, toLogin, successToShow, errorToShow, debounce } from '@/config/common.js';
import { getAppMyAttentionList, cancelAttention } from '@/constant/customer.js';
export default {
	data() {
		return {
			customerId: uni.getStorageSync('customerId'),
			followList: [],
			query_filter: {
				customerId: uni.getStorageSync('customerId'),
				pageNum: 1,
				pageSize: 10
			},
			noClick: true
		};
	},
	onLoad() {
		if (isLogin()) {
			this.getAttationList();
		} else {
			toLogin();
		}
	},
	onReachBottom() {
		this.query_filter.pageNum++;
		this.getAttationList();
	},
	onPullDownRefresh() {
		this.query_filter.pageNum = 1;
		this.getAttationList();
	},
	methods: {
		async getAttationList() {
			//订单列表
			let res = await getAppMyAttentionList(this.query_filter);
			uni.stopPullDownRefresh();
			if (this.query_filter.pageNum > 0) {
				for (let i = 0; i < res.rows.length; i++) {
					let obj = res.rows[i];
					this.followList.push(obj);
				}
			} else {
				this.followList = res.rows;
			}
		},
		cancel_attention(servePlayerId) {
			//取消关注
			debounce(() => {
				this.imp_cancelattention(servePlayerId);
			}, 500)();
		},
		async imp_cancelattention(servePlayerId) {
			if (this.customerId) {
				await cancelAttention({
					id: servePlayerId,
					customerId: this.customerId
				});
				successToShow('取消关注', res => {
					this.getAttationList();
				});
			}
		}
	}
};
</script>
<style>
@import url('../../../css/common.css');
</style>
<style scoped lang="scss">
.container {
	background-color: $main-page-color;
	height: 100vh;
	// overflow-y: auto;
}
.person-info-container {
	display: flex;
	flex-direction: column;
}
.person-info {
	height: 220rpx;
	&__header {
		&-img {
			width: 100rpx;
			height: 100rpx;
			border-radius: 50%;
		}

		font-size: 30rpx;
		display: flex;
		align-items: center;
		padding: 20rpx;

		.user-id {
			font-size: 28rpx;
			color: #999999;
		}

		.user-content {
			font-size: 28rpx;
			color: #999999;
			width: 500rpx;
			overflow: hidden;
			display: block;
			height: 40rpx;
			margin-top: 10rpx;
		}
	}

	&__bottom {
		display: flex;
		align-items: center;
		justify-content: space-around;
		font-size: 28rpx;
		color: $main-text-color-gray-33;
		&-item {
			display: flex;
			align-items: center;
		}
		&-icon {
			width: 30rpx;
			height: 30rpx;
			margin-right: 10rpx;
		}
		.flow-btn {
			background-color: rgb(208, 208, 208);
			color: #fff;
			padding: 10rpx 20rpx 10rpx 20rpx;
			border-radius: 10rpx;
			font-size: 28rpx;
		}
	}
}
.no-content {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 100vh;
	width: 100%;
}
</style>
